import { createLogger } from '@/utils/front/logger';

const logger = createLogger('store');

const loggerMiddleware =
  (store: { getState: () => any }) =>
  (next: (arg0: any) => any) =>
  (action: any) => {
    if (globalThis.process) {
      return next(action);
    }

    logger.info('dispatching:', action);
    const result = next(action);
    logger.info('newState:', store.getState());
    return result;
  };

export default loggerMiddleware;
